package org.example.day20240820;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String data = scanner.nextLine();
//        5 2 6 20 40 100 80      5个居民 2个坐标连续在矩形则有危险 6个坐标 矩形坐标1 矩形坐标2
//        100 80 100 80 100 80 100 80 100 80 100 80
//        60 50 60 46 60 42 60 38 60 34 60 30
//        10 60 14 62 18 66 22 74 26 86 30 100
//        90 31 94 35 98 39 102 43 106 47 110 51
//        0 20 4 20 8 20 12 20 16 20 20 20
        String[] dataArr = data.split(" ");
        int peopleNum = Integer.parseInt(dataArr[0]);
        int dangerNum = Integer.parseInt(dataArr[1]);
        int pointNum = Integer.parseInt(dataArr[2]);
        Point point1 = new Point(Integer.parseInt(dataArr[3]),Integer.parseInt(dataArr[4]));
        Point point2 = new Point(Integer.parseInt(dataArr[5]),Integer.parseInt(dataArr[6]));
        int result = 0;
        int result2 = 0;
        for(int i=0; i<peopleNum; i++){
            int dangerCount = 0;
            int peopleCount = 0;
            List<Point> pointList = new ArrayList<>();
            String point = scanner.nextLine();
            String[] pointArr = point.split(" ");
            for(int j=0; j<pointArr.length-1; j+=2){
                Point point3 = new Point(Integer.parseInt(pointArr[j]),Integer.parseInt(pointArr[j+1]));
                pointList.add(point3);
            }
            for(Point point4 : pointList){
                if(point4.isiru(point2,point1)){
                    dangerCount++;
                    peopleCount++;
                }else{
                    dangerCount = 0;
                }
                if(dangerCount>=dangerNum){
                    result++;
                    break;
                }
            }

            if(peopleCount>0){
                result2++;
            }
        }
        if(result>0){
            System.out.println(result2);
            System.out.println(result);
        }else {
            System.out.println(result2);
            System.out.println(result);
        }
    }
}
